package com.ilink.teacherservice.controller.xiaolian;

import com.ilink.ilinkcommon.domain.R;
import com.ilink.ilinkcommon.log.method.MethodLog;
import com.ilink.teacherservice.service.impl.xiaolian.XiaolianConversationCountServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/teacher")
public class XiaolianConversationCountServiceController {

    @Autowired
    private XiaolianConversationCountServiceImpl xiaolianConversationCountService;

    /**
     * 查询所有对话记录及其回答次数
     *
     * @return 返回查询结果，包括user_input, assistant_reply, 及对应的次数
     */
    @MethodLog("查询所有对话记录和回答次数")
    @GetMapping("/getAllConversationCounts")
    public R<List<Map<String, Object>>> getAllConversationLogs(@RequestParam(required = false) Long courseFileId) {
        List<Map<String, Object>> logs = xiaolianConversationCountService.getAllConversationLogsWithCount(courseFileId);
        return R.ok(logs); // 使用R.ok()包装返回结果
    }
}
